package xyz.xtt.asset.client.request;

import java.math.BigDecimal;
import java.util.List;
import java.util.Objects;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.Max;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotBlank;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Builder.Default;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class MintRequest {
	@NotBlank(message = "description不能为空")
	private String description;
	@Schema(description = "扩展信息")
	private String externalUrl;
	@NotBlank(message = "展示图不能为空")
	private String image;
	@NotBlank(message = "资产名称不能为空")
	private String name;
	@Schema(description = "上链字段信息")
	// @Valid
	// @NotNull(message = "上链属性不能为空")
	// @NotEmpty(message = "上链属性不能为空")
	private List<MintDataVo> attributes;
	@NotBlank(message = "作者appUid")
	private String authorId;
	@Schema(description = "合约类型 721/1155")
	// @EnumValue(stringValues = { "721", "1155" }, message =
	// "合约类型取值不正确,可先值721/1155")
	private String referProtocol;
	@Schema(description = "资产类型编码")
	private String assetType;
	@Schema(description = "业务方id")
	private String bizId;
	@Schema(description = "链框架id")
	private Integer chainId;
	@Schema(description = "资产数量")
	private Integer amount;
	@Schema(description = "资产价格")
	private BigDecimal price;
	@Schema(description = "支付单位 1 通宝 2通钻 3人民币")
//	@Range(min = 0, max = 3, message = "资产计价单位不正确 1 通宝 2通钻 3人民币")
	private Integer unit;
	@Schema(description = "业务类型")
	private String bizType;
	@Schema(description = "出售开始时间")
	@Default
	private Long sellStartDatetime = 0L;
	@Schema(description = "出售结束时间")
	@Default
	private Long sellEndDatetime = 0L;
	@Schema(description = "展示状态2上架3下架")
	private Integer showState;
	@Schema(description = "资产的拥有人0个人1平台2代理商")
	@Default
	@Min(value = 0, message = "有效取值为为0-2")
	@Max(value = 2, message = "有效取值为为0-2")
	private Integer ownerType = 1;
	@Schema(description = "关联资产id 内部字段")
	@Default
	private Long parentId = 0L;
	@Schema(description = "资产顺序号 内部字段")
	@Default
	private Long seqNo = 0L;
	@Schema(description = "资产二级分类 内部字段")
	@Default
	private Integer secondType = 0;
	@Schema(description = "拥有人 内部字段")
	@Default
	private String ownerId = "";
	@Schema(description = "订单号")
	@Default
	private String orderNo = "";
	@Schema(description = "展示url 内部字段")
	@Default
	private String displayUri = "";
	/**
	 * 是否上链
	 */
	@Default
	private Boolean upChain = Boolean.TRUE;
	
	@Schema(description = "是否可售卖")
	@Default
	private Integer sellable = 0;

	@Schema(description = "是否可赠送")
	@Default
	private Integer giftable = 0;

	@Schema(description = "是否可参与排行榜")
	@Default
	private Integer rankable = 0;

	@Schema(description = "根资产id")
	@Default
	private Long rootAssetId = 0L;

	@Schema(description = "是否可见")
	@Default
	private Integer visiable = 1;

	@Schema(description = "风格ID")
	@Default
	private Long collectionId = 0L;

	public Boolean checkAmount() {
		return Objects.nonNull(amount) && amount.intValue() > 0;
	}

	public Boolean checkAmountWithOne() {
		return Objects.nonNull(amount) && amount.intValue() == 1;
	}
}
